using System;
using System.Collections.Generic;
using System.Text;
using Objects;

namespace DAL
{
    public class DALPhuongThucThanhToan
    {
        public List <PhuongThucThanhToan> GetAllItem()
        {
            List<PhuongThucThanhToan> ListPhuongThucThanhToan = new List<PhuongThucThanhToan>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("PhuongThucThanhToan_GetAllItem", sname, vname);

            PhuongThucThanhToan Item = new PhuongThucThanhToan();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                System.Data.DataRow dr = ds.Tables[0].Rows[i];
                ListPhuongThucThanhToan.Add((Item.Populate(dr)));
            }
            return ListPhuongThucThanhToan;
        }


        public int Insert_PhuongThucThanhToan(String HinhThuc, String GhiChu,String DuongDan,int Status ,int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@HinhThuc", "@GhiChu","@DuongDan" ,"@Status", "@SapXep" };
            string[] vname = new string[] { HinhThuc.ToString(), GhiChu.ToString(), DuongDan.ToString() ,Status.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("PhuongThucThanhToan_Insert", sname, vname);

        }

        public int Update_PhuongThucThanhToan(int id, String HinhThuc, String GhiChu, String DuongDan,int Status ,int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Id", "@HinhThuc", "@GhiChu", "@DuongDan" ,"@Status", "@SapXep" };
            string[] vname = new string[] { id.ToString(), HinhThuc.ToString(), GhiChu.ToString(),DuongDan.ToString() ,Status.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("PhuongThucThanhToan_Update", sname, vname);

        }

        public int Delete_PhuongThucThanhToan(int id)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@id" };
            string[] vname = new string[] { id.ToString() };
            return acc.InsertUpdateDetete("PhuongThucThanhToan_Delete", sname, vname);

        }

        public PhuongThucThanhToan GetById(int Id)
        {
            clsDataAccess acc = new clsDataAccess();
            string[] sname = new string[] {"Status", "@Id" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString() ,Id.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("PhuongThucThanhToan_GetById", sname, vname);
            PhuongThucThanhToan Item = new PhuongThucThanhToan();

            System.Data.DataRow dr = ds.Tables[0].Rows[0];
            return Item.Populate(dr);
        }
    }
}
